home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 2,801 to 2,900
/
aol-file-protocol-4400-2801-to-2900.zip
/
AOLDLs
/
C++ Files Library
/
MRDiim, 3D World Shell
/
MRDiim.sit
/
MRDiim
/
MRDiim.cp
< prev
next >
Wrap
Text File
|
1994-12-19
|
6KB
|
171 lines
#include<QDOffScreen.h>
#include"Utils_General.h"
#include"MRRachet.h"
#include"MREyeBall.h"
#include"MRConstruction.h"
#include"MRDiim.h"
#include <math.h>
MRDoom::MRDoom(short Number,Boolean toMark): MREyeBall(Number,toMark)
{
// slide is a timer specific to each window, set on it's doidlewindow
slide=0;
// facing is the angle you are facing in radians
facing=0;
// half circle allows representation of 360 degrees of the circle when using tan (which returns 0-180 degrees)
halfCircle=false;
// starting postion
myself.myX=5;
myself.myY=10;
// refresh window on next doidlewindow
DirtyWindow=true;
// build the world.
myConstruction= new MRConstruction();
// posts
// myConstruction -> AddConstruction(ReturnChartPost(0,0));
// myConstruction -> AddConstruction(ReturnChartPost(1,1));
// myConstruction -> AddConstruction(ReturnChartPost(2,2));
// myConstruction -> AddConstruction(ReturnChartPost(3,3));
// myConstruction -> AddConstruction(ReturnChartPost(3,6));
// myConstruction -> AddConstruction(ReturnChartPost(6,3));
// myConstruction -> AddConstruction(ReturnChartPost(6,6));
// myConstruction -> AddConstruction(ReturnChartPost(7,7));
// myConstruction -> AddConstruction(ReturnChartPost(8,8));
// myConstruction -> AddConstruction(ReturnChartPost(9,9));
// walls. use either 0 or 1 for the last argument (texture set)
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(2,4),ReturnChartPost(4,4)),1);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(4,4),ReturnChartPost(4,2)),0);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(4,2),ReturnChartPost(6,2)),0);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(6,2),ReturnChartPost(6,4)),0);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(6,4),ReturnChartPost(8,4)),0);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(8,4),ReturnChartPost(8,8)),0);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(8,8),ReturnChartPost(6,8)),0);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(6,8),ReturnChartPost(6,6)),0);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(6,6),ReturnChartPost(4,6)),0);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(4,6),ReturnChartPost(4,8)),0);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(4,8),ReturnChartPost(2,8)),0);
myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(2,8),ReturnChartPost(2,4)),0);
// boundries
// myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(0,0),ReturnChartPost(10,0)));
// myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(0,0),ReturnChartPost(0,10)));
// myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(10,0),ReturnChartPost(10,10)));
// myConstruction -> AddConstruction(ReturnChartWall(ReturnChartPost(0,10),ReturnChartPost(10,10)));
}
MRDoom::~MRDoom(void)
{
delete (myConstruction);
}
void *MRDoom::NewRachet(short Number,Boolean toMark)
{
return(new MRDoom(Number,toMark));
}
void MRDoom::ZapRachet(Ptr toBeZapped)
{
delete (MRDoom *) toBeZapped;
}
void MRDoom::DoGWorldContent(void)
{ // fill up the gworld with content. Pen & colors have been saved by class . Port has been set.
short countX=0,countY=0;
Point refPoint={0,0};
RGBForeColor(&BlackPen);
// find locations, mark, and prepStart.
myConstruction->FindActors(myself,facing,halfCircle);
myConstruction->PrepScanStart();
// while marked, scan construction, build next thing, and reprep
while(myConstruction->HasRachetsOfPolarity(true))
{
myConstruction->ScanConstruction();
myConstruction->PrepScan();
}
}
void MRDoom::DoKeyDown(EventRecord event,char key)
{ // handle keys application doesn't want
ChartPost oldSelf=myself;
switch(key)
{
case '7': // rotate left
{
facing-=RotateAmount;
break;
}
case '9': // rotate right
{
facing+=RotateAmount;
break;
}
case '8': // move forward
{
myself.myX-= cos(facing+MyHalfPi)*(halfCircle? -1:1)*HumanStep;
myself.myY-= sin(facing+MyHalfPi)*(halfCircle? -1:1)*HumanStep;
break;
}
case '4': // move left
{
myself.myX-= cos(facing)*(halfCircle? -1:1)*HumanStep;
myself.myY-= sin(facing)*(halfCircle? -1:1)*HumanStep;
break;
}
case '2': // move back
{
myself.myX+= cos(facing+MyHalfPi)*(halfCircle? -1:1)*HumanStep;
myself.myY+= sin(facing+MyHalfPi)*(halfCircle? -1:1)*HumanStep;
break;
}
case '6': // move right
{
myself.myX+= cos(facing)*(halfCircle? -1:1)*HumanStep;
myself.myY+= sin(facing)*(halfCircle? -1:1)*HumanStep;
break;
}
default:
SysBeep(30);
}
if(!myConstruction->ProposedMove(myself) && !GudMode)
myself=oldSelf; // not a good move
else
{
DirtyWindow=true; // better refresh window next idle pass
NormalizeAngle(facing, halfCircle);
}
}
void MRDoom::DoIdleWindow(void)
{ // called when there are no other events to handle. active/front window gets call only
slide+=1;
if(slide>95)
slide=0;
if(DirtyWindow)
{
DoUpdateGWorld();
FixTopWindow(GetStoreWindow());
DirtyWindow=false;
}
}
void MRDoom::ClearWindowContent(WindowPtr window)
{ // called by the window class after setting port and before calling content
Rect myWindRect=window->portRect;
myWindRect.bottom=HorizonLine;
RGBForeColor(&CyanPen);
FillRect(&myWindRect,black);
myWindRect=window->portRect;
myWindRect.top=HorizonLine;
RGBForeColor(&BluePen);
FillRect(&myWindRect,black);
}